# -*- coding: utf-8 -*-
# File:get_cookies.py
# Time: 
# Author : xingtiantian

import yaml
from selenium import webdriver
from time import sleep

def get_cookies():
    driver = webdriver.Chrome()
    driver.get("https://work.weixin.qq.com/wework_admin/loginpage_wx")
    sleep(15)
    #等待手工扫码后，获取cookies
    cookies = driver.get_cookies()
    #将cookies写入cookie.yaml文件
    with open("../datas/cookies.yaml", "w") as f:
        yaml.safe_dump(cookies, f)
        print(f"成功将cookies写入cookies.yaml文件")

if __name__ == '__main__':
    get_cookies()